//
//  ZMFourthVC.m
//  demo
//
//  Created by chenzm on 2018/8/17.
//  Copyright © 2018年 chenzm. All rights reserved.
//

#import "ZMFourthVC.h"

#import "ZMPerson.h"

@interface ZMFourthVC ()

@property (nonatomic, strong) ZMPerson *person;

@end

@implementation ZMFourthVC

- (void)initView {
    [super initView];
    _person = [ZMPerson new];
    NSLog(@"%@",_person.coding);
    NSLog(@"%@",_person.eating);
    
    
}



- (NSArray *)buttonTitleArray {
    return @[@"交换", @"不交换"];
}

- (void)buttonClick:(UIButton *)sender {
    if (sender.tag == 0) {
        [self exchangeMethod];
    }
    NSString *str = [NSString stringWithFormat:@"%@_%@",[_person coding],[_person eating]];
    self.testLabelText = str;
    NSLog(@"%@",_person.coding);
    NSLog(@"%@",_person.eating);
}

///交换方法
-(void)exchangeMethod{
    Method aMethod = class_getInstanceMethod([_person class], @selector(coding));
    Method bMethod = class_getInstanceMethod([_person class], @selector(eating));
    method_exchangeImplementations(aMethod, bMethod);
}




@end
